<?php

/**
* @author Jasman
* @Copyright (c) 2010 Ihsana IT Solution (www.ihsana.com)
* Thank to http://www.myjurnal.in
* Licensed under the MIT license
* http://www.opensource.org/licenses/mit-license.php
*/

$referal = $_SERVER["HTTP_REFERER"] ;
$referal = urldecode($referal);
$referal = str_replace("www.","",$referal);
$referal = str_replace("http://","",$referal);
$PecahReferal = explode("/", $referal);
$searchEngine = $PecahReferal[0] ;

if ($searchEngine == "google.co.id" ){
$StartReferal = explode('q=',$referal);
$EndReferal = explode('&',$StartReferal[1]);
$keyword = $EndReferal[0];
echo $keyword ;//Insert MySQL
};

if ($searchEngine == "google.com" ){
$StartReferal = explode('q=',$referal);
$EndReferal = explode('&',$StartReferal[1]);
$keyword = $EndReferal[0];
echo $keyword ;//Insert MySQL
};

if ($searchEngine == "bing.com" ){
$StartReferal = explode('q=',$referal);
$EndReferal = explode('&',$StartReferal[1]);
$keyword = $EndReferal[0];
echo $keyword ;//Insert MySQL
};
?>
